package Behavioral_design_pattern.Iterator_Pattern;

public class TCLTelevision implements Television {
    private Object[] obj = {"CCTV1","CCTV2","CCTV3"};
    @Override
    public TVIterator createIterator() {
        return new TCLIterator();
    }

    public class TCLIterator implements TVIterator {

        private int currentIndex = 0;
        @Override
        public void setChannel(int i) {
            currentIndex = i;
        }

        @Override
        public Object currentChannel() {
            return obj[currentIndex];
        }

        @Override
        public void next() {
            if(currentIndex<obj.length){
                currentIndex++;
            }
        }

        @Override
        public void previous() {
            if(currentIndex>0){
                currentIndex--;
            }
        }

        @Override
        public boolean isLast() {
            return currentIndex==obj.length;
        }

        @Override
        public boolean isFirst() {
            return currentIndex==0;
        }
    }
}
